<template>
  <div :class="['cover',{'inner-cover':isInline}]">
    <div class="image">
      <ImageVideo class="vant-image" :src="src" :fit="fit" />
    </div>
    <div class="cover-name">{{ name }}</div>
  </div>
</template>
<script>
import errorImage from '@/assets/error.png'
import ImageVideo from '@/components/ImageVideo'
export default {
  name: 'Cover',
  components: {
    ImageVideo
  },
  props: {
    isInline: {
      type: Boolean,
      default: false
    },
    src: {
      type: String,
      default: ''
    },
    name: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      errorImage,
      fit: 'fit'
    }
  },
  methods: {
  }
}
</script>
<style lang="less" scoped>
.cover{
  background: #FFF;
  border-radius: 4px;
  box-sizing: border-box;
  padding: 10px;
  overflow: hidden;
  position: relative;
  width: 100%;
  flex: 0 0 100%;
  margin: 0;
  --width:calc(100vw - 32px - 20px);
  &.inner-cover{
    --width:calc(100vw - 120px - 32px - 20px);
  }
  --ImgHeight: calc(var(--width) * 178/323);
  & .image{
    width:var(--width);
    height:var(--ImgHeight);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    z-index: 3;
    & .vant-image{
      width: inherit;
      height: inherit;
    }
  }
  &::before{
    content: "";
    display: block;
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    height:var(--ImgHeight);
    border-radius: 4px;
    background-color: #CCCCCC;
    z-index: 2;
  }
  &::after{
    content: "";
    display: block;
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 60px);
    height:var(--ImgHeight);
    border-radius: 4px;
    background-color: #F0F0F0;
    z-index: 1;
  }
  .cover-name{
    margin-top: 30px;
    width: 100%;
    height: 20px;
    line-height: 20px;
    font-size: 14px;
    color: #333;
    text-align: center;
    font-weight: 600;
    .textOverflow(100%)
  }
  &.inner-cover{
    .cover-name{
      margin-top: 20px;
    }
    &::before{
      top: 15px;
    }
    &::after{
      top:20px
    }
  }
}
</style>
